﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using FCS.GlobalComponents;
using System.Net;

namespace FCS.Communication
{
    /// <summary>
    /// Service contract for the CPQ
    /// </summary>
    [ServiceContract(Namespace="http://enlight-server.engr.wisc.edu/")]
    public interface ICPQ
    {
        // Non secure commands
        /// <summary>
        /// Returns a list of the currently active valves on the fountain
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        List<string> GetActiveValves();

        /// <summary>
        /// Returns a list of the currently active weirs on the fountain
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        List<string> GetActiveWeirs();

        /// <summary>
        /// Returns a list of the currently active winter components (i.e. lights) on the fountain
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        List<string> GetActiveWinterComponents();
        
        /// <summary>
        /// Returns the state of the bollards, pumps, and environment
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        cRIOState GetResources();

        /// <summary>
        /// Returns the current threshold e.g. Kiosk
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        CommandPriority GetThreshold();

        /// <summary>
        /// Returns a list of restricted valves for a certain priority level
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        [OperationContract]
        List<string> GetRestrictedValves(CommandPriority cp);

        /// <summary>
        /// Returns the state of the bollards, pumps, and environment
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        FountainResources GetResourceStatus();

        // secure commands

        /// <summary>
        /// Sends a command to the cRIO
        /// </summary>
        /// <param name="state">ON or OFF</param>
        /// <param name="command">List of valves, wiers, or winter components</param>
        /// <param name="cp">Priority of command</param>
        /// <param name="secCode">Security code</param>
        /// <returns></returns>
        [OperationContract]
        bool SendCommand(string state, List<string> command, CommandPriority cp, string secCode);

        /// <summary>
        /// Adds restricted valves to a priority level
        /// </summary>
        /// <param name="valveList"></param>
        /// <param name="cp"></param>
        /// <param name="secCode"></param>
        [OperationContract]
        void AddRestrictedValves(List<string> valveList, CommandPriority cp, string secCode);

        /// <summary>
        /// Removes restricted valves from a priority level
        /// </summary>
        /// <param name="valveList"></param>
        /// <param name="cp"></param>
        /// <param name="secCode"></param>
        [OperationContract]
        void RemoveRestrictedValves(List<string> valveList, CommandPriority cp, string secCode);

        /// <summary>
        /// Resets the priority threshold level back to pattern
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="secCode"></param>
        [OperationContract]
        void ResetThreshold(CommandPriority cp, string secCode);

        /// <summary>
        /// Sets the server up to connect to the default cRIO address
        /// </summary>
        /// <param name="secCode"></param>
        [OperationContract]
        void SetDefaultCRIOAddress(string secCode);

        /// <summary>
        /// Sets the server up to connect to a non-default cRIO address. Useful for debugging
        /// </summary>
        /// <param name="address"></param>
        /// <param name="localPort"></param>
        /// <param name="endPointPort"></param>
        /// <param name="secCode"></param>
        [OperationContract]
        void SetCRIOAddress(String address, int localPort, int endPointPort, string secCode);
    }
}
